<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="list" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <h:panelGroup rendered="#{cc.attrs.list.bills.size()!=0}">
            <table  class="summery" style="min-width: 100%;">
                <thead >
                    <td>
                        <h:outputLabel value="Time" />
                    </td>
                    <td>
                        <h:outputLabel value="Cancelled Id"/>
                    </td>
                    <td>
                        <h:outputLabel value="Billed Id"/>
                    </td>
                    <td>
                        <h:outputLabel value="Patient Name"/>
                    </td>
                    <td style="text-align: right;">
                        <h:outputLabel value="Dis"/>
                    </td>
                    <td style="text-align: right;">
                        <h:outputLabel value="Cash"/>
                    </td>
                    <td style="text-align: right;">
                        <h:outputLabel value="Credit"/>
                    </td>
                    <td style="text-align: right;">
                        <h:outputLabel value="C Card"/>
                    </td>

                    <td style="text-align: right;">
                        <h:outputLabel value="Cheque"/>
                    </td>
                    <td style="text-align: right;">
                        <h:outputLabel value="Slip"/>
                    </td>
                    <td >

                    </td>

                </thead>
                <ui:repeat value="#{cc.attrs.list.bills}" var="b">
                    <tr>
                        <td>
                            <h:outputLabel value="#{b.createdAt}" >
                                <f:convertDateTime pattern="h:mm a"/>
                            </h:outputLabel>
                        </td>
                        <td>
                            <h:outputLabel value="#{b.insId}"/>
                        </td>
                        <td>
                            <h:outputLabel value="#{b.billedBill.insId}"/>
                        </td>
                        <td>
                            <h:outputLabel value=" #{b.patient.person.nameWithTitle}"/>  
                        </td>
                        <td style=" text-align: right;">
                            <h:outputLabel value="#{b.discount}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>  
                        </td>
                        <td style=" text-align: right;">
                            <h:outputLabel rendered="#{b.paymentMethod=='Cash'}" value="#{b.netTotal}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel rendered="#{b.paymentMethod!='Cash'}" value="0.00" />
                        </td>
                        <td style=" text-align: right;">
                            <h:outputLabel rendered="#{b.paymentMethod=='Credit'}" value="#{b.netTotal}"  >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel rendered="#{b.paymentMethod!='Credit'}" value="0.00"/>
                        </td>
                        <td style=" text-align: right;">
                            <h:outputLabel rendered="#{b.paymentMethod=='Card'}" value="#{b.netTotal}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel rendered="#{b.paymentMethod!='Card'}" value="0.00"/>
                        </td>
                        <td style=" text-align: right;">
                            <h:outputLabel rendered="#{b.paymentMethod=='Cheque'}" value="#{b.netTotal}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel rendered="#{b.paymentMethod!='Cheque'}" value="0.00"/>
                        </td>
                        <td style="text-align: right;">
                            <h:outputLabel rendered="#{b.paymentMethod=='Slip'}" value="#{b.netTotal}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel rendered="#{b.paymentMethod!='Slip'}" value="0.00"/>          
                        </td>
                        <td>
                            <p:selectBooleanCheckbox style="border: black 2px solid;"/>
                        </td>
                    </tr>
                </ui:repeat>
                <tfoot  >
                    <td colspan="5">
                        <h:outputLabel value="Total : "/>
                    </td>
                    <td style=" text-align: right">
                        <h:outputLabel value="#{cc.attrs.list.cash}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                    </td>
                    <td style=" text-align: right">
                        <h:outputLabel value="#{cc.attrs.list.credit}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                    </td>
                    <td style=" text-align: right">
                        <h:outputLabel value="#{cc.attrs.list.card}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                    </td>
                    <td style=" text-align: right"> 
                        <h:outputLabel value="#{cc.attrs.list.cheque}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                    </td>
                    <td style=" text-align: right">
                        <h:outputLabel value="#{cc.attrs.list.slip}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </h:outputLabel>
                    </td>
                </tfoot>
            </table>
        </h:panelGroup>
    </cc:implementation>
</html>